Sub state vector#8077
Conversation
The current implementation appears to be exponential in space and time. The present change, due originally to jamieas@google.com, replaces python loops with numpy functions motivated by standard methods for computing partial traces. The change is runnable in Colab, including tests and a performance benchmark, at https://colab.sandbox.google.com/drive/1qWJTnlT6hPXI8cQsTwyqQveEtn7fGhNc?resourcekey=0-67OmbvgwTlf9fnKp3ppbrw
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #8077 +/- ##
=======================================
Coverage 99.63% 99.63%
=======================================
Files 1110 1110
Lines 100067 100074 +7
=======================================
+ Hits 99705 99712 +7
Misses 362 362 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
CLA check is fixed. |
NoureldinYosri
left a comment
There was a problem hiding this comment.
overall LGTM%nits
| num_qubits_out = len(keep_indices)#.shape[0] | ||
|
|
||
| # The permutation moves the specified qubits to the start of the qubit order. | ||
| keeps = set(keep_indices) |
| if protocols.approx_eq(coherence_measure, 1, atol=atol): | ||
| return np.exp(2j * np.pi * np.random.random()) * best_candidate.reshape(ret_shape) | ||
| # The number of output qubits. | ||
| # keep_indices = np.array(keep_indices) |
There was a problem hiding this comment.
| # keep_indices = np.array(keep_indices) |
| return np.exp(2j * np.pi * np.random.random()) * best_candidate.reshape(ret_shape) | ||
| # The number of output qubits. | ||
| # keep_indices = np.array(keep_indices) | ||
| num_qubits_out = len(keep_indices)#.shape[0] |
There was a problem hiding this comment.
| num_qubits_out = len(keep_indices)#.shape[0] | |
| num_qubits_out = len(keep_indices) |
NoureldinYosri
left a comment
There was a problem hiding this comment.
thanks @AntonKast
- Verify the maximum eigenvalue is indeed close to 1. - Enable arbitrary order of `keep_indices` as before. - Use the same tolerance check as before quantumlib#8077 with rtol=0. This allows to restore previous tests instead of having to do them with larger state vector deviation. - Put back RaiseValueErrorIfNotProvided as a default for `sub_state_vector`. This allows using `None` for the fallback return value. - Add check for negative values in `keep_indices`. Follow-up to quantumlib#8077
The current implementation appears to be exponential in space and time. The present change, due originally to jamieas@google.com, replaces python loops with numpy functions motivated by standard methods for computing partial traces. The change is runnable in Colab, including tests and a performance benchmark, at
https://colab.sandbox.google.com/drive/1qWJTnlT6hPXI8cQsTwyqQveEtn7fGhNc?resourcekey=0-67OmbvgwTlf9fnKp3ppbrw